<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        const obj = {
            name: "zs",
            age: 18,
            sex: "男",
            girlfriend: {
                name: "ls",
                age: 18,
                sex: "女"
            },
            say() {
                console.log('我的名字是' + this.name, '这是我的女朋友' + this.girlfriend.name);
            }
        }
        const o1 = { ...obj }
        const o2 = {}
        Object.assign(o2, obj)
        console.log('我是obj的年龄' + obj.age);
        console.log('我是o1的年龄' + o1.age);
        console.log('我是o2的年龄' + o2.age);
        console.log('--------------------------------')
        obj.say()
        o1.say()
        o2.say()
        console.log('--------------------------------')
        o1.age = 20;
        o2.age = 22;
        o1.name = "ww"
        o2.name = "xl"
        o2.girlfriend.name = "wff"
        console.log('--------------------------------')
        console.log('我是obj的年龄' + obj.age);
        console.log('我是o1的年龄' + o1.age);
        console.log('我是o2的年龄' + o2.age);
        console.log('--------------------------------')
        obj.say()
        o1.say()
        o2.say()
        console.log('--------------------------------')
        o1.girlfriend.name = "lxl"
        obj.say()
        o1.say()
        o2.say()

        //   o1.girlfriend.name = "lxl"
    </script>
</body>

</html>